package com.lhd.struct.flyweight;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: liuhd
 * @Date: 2024/12/16 21:00
 * @Description: 享元工厂类
 */
public class BoxFactory {
    private final Map<String,AbstractBox> boxes = new HashMap<>();
    private static BoxFactory boxFactory = new BoxFactory();
    private BoxFactory(){
        boxes.put("I",new IBox());
        boxes.put("L",new LBox());
        boxes.put("O",new OBox());
    }

    public static BoxFactory getBoxFactory() {
        return boxFactory;
    }
    public AbstractBox getBox(String shape){
        return boxes.get(shape);
    }
}
